import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import';
const { resolve } = require('path')

const NODE_ENV = process.env.NODE_ENV;

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'vant',
          esModule: true,
          resolveStyle: (name) => `vant/es/${name}/style`,
        },
      ],
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname,'./src')
    },
    extensions: ['.js', '.json', '.ts', '.mjs'] // 使用路径别名时想要省略的后缀名，可以自己增减
  },
  css: {
    preprocessorOptions: {
      // scss: {
      //   additionalData: `@import "./src/assets/css/variable.scss";`
      // },
      less: {
        modifyVars: {
          hack: `true; @import (reference) "${resolve('src/assets/css/variable.less')}";`,
        },
        javascriptEnabled: true,
      }
    },
  },
  build: {
    outDir: 'dist',
    // 打包路径
    assetsDir: "static",
    rollupOptions: {
      input: '/index.html'
    },
  },
  
})
